home *** CD-ROM | disk | FTP | other *** search
- // This is part of the iostream library, providing input/output for C++.
- // Copyright (C) 1991 Per Bothner.
- //
- // This library is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Library General Public
- // License as published by the Free Software Foundation; either
- // version 2 of the License, or (at your option) any later version.
- //
- // This library is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- // Library General Public License for more details.
- //
- // You should have received a copy of the GNU Library General Public
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- #include "ioprivat.h"
- #include <fstream.h>
- #include <std.h>
- #include <sys/file.h>
- #ifdef __GNUG__
- #pragma implementation
- #endif
-
- ifstream::ifstream()
- {
- _strbuf = new filebuf();
- }
-
- ifstream::ifstream(int fd)
- {
- _strbuf = new filebuf(fd);
- }
-
- ifstream::ifstream(char *name, int mode=ios::in, int prot=0664)
- {
- #if 1
- _strbuf = new filebuf();
- ((filebuf*)_strbuf)->open(name, mode, prot);
- #else
- _flags |= ios::dont_close;
- open(name, mode, prot);
- #endif
- }
-
- ofstream::ofstream()
- {
- _strbuf = new filebuf();
- }
-
- ofstream::ofstream(int fd)
- {
- _strbuf = new filebuf(fd);
- }
-
- ofstream::ofstream(char *name, int mode=ios::out, int prot=0664)
- {
- #if 1
- _strbuf = new filebuf();
- ((filebuf*)_strbuf)->open(name, mode, prot);
- #else
- _flags |= ios::dont_close;
- open(name, mode, prot);
- #endif
- }
-
- #if 0
- static int mode_to_sys(enum open_mode mode)
- {
- return O_WRONLY;
- }
-
- static char* fopen_cmd_arg(io_mode i)
- {
- return "w";
- }
- #endif
-
- void ifstream::open(char *name, int mode=ios::in, int prot=0664)
- {
- rdbuf()->open(name, mode, prot);
- }
-
- void ifstream::close()
- {
- rdbuf()->close();
- }
-
- void ofstream::close()
- {
- rdbuf()->close();
- }
-
- void ofstream::open(char *name, int mode=ios::out, int prot=0664)
- {
- rdbuf()->open(name, mode, prot);
- }
-